package com.wyl.xue.admin.system.mybatis.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wyl.xue.admin.system.mybatis.entity.SystemMenu;
import com.wyl.xue.admin.system.mybatis.mapper.SystemMenuMapper;
import com.wyl.xue.admin.system.mybatis.service.SystemMenuService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


/**
 * @ClassName: SystemMenuServiceImpl
 * @Function: 菜单
 * @Date: 2019/12/18 22:12
 * @author wyl
 * @version V1.0
 */
@Service
@Slf4j
@AllArgsConstructor
@DS("master")
public class SystemMenuServiceImpl extends ServiceImpl<SystemMenuMapper, SystemMenu> implements SystemMenuService {


    /**
     * @Description 是否有子菜单
     * @param menuId
     * @return java.lang.Boolean
     * @Date 2020/11/21 22:41
     * @Author wangyl
     * @Version V1.0
     */
    @Override
    public Boolean haschildMenu(long menuId) {
        LambdaQueryWrapper<SystemMenu> systemMenuLambdaQueryWrapper = Wrappers.lambdaQuery(SystemMenu.class)
                                                                              .eq(SystemMenu::getParentId, menuId)
                                                                              .last("limit 1");
        return !list(systemMenuLambdaQueryWrapper).isEmpty();
    }
}
